package com.kexl.activiti.demo;

import org.apache.catalina.Context;
import org.apache.tomcat.util.scan.StandardJarScanner;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

/**
 * @classname: ActivitiDemoApplication
 * @description:
 * @author: kexl
 * @create: 2021-03-10 18:16
 * @version: 1.0
 **/
@SpringBootApplication
@MapperScan(basePackages = {"com.kexl.activiti.demo.*.mapper"})
public class ActivitiDemoApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ActivitiDemoApplication.class);
    }

    /**
     * 解决高版本springboot 启动 tomcat8扫描不到jar包的问题
     * @return
     */
    @Bean
    public TomcatServletWebServerFactory tomcatFactory(){
        return new TomcatServletWebServerFactory(){

            @Override
            protected void postProcessContext(Context context) {
                ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
            }
        };
    }
    public static void main(String[] args) {
        SpringApplication.run(ActivitiDemoApplication.class,args);
    }
}

